<%@ page language="java" import="java.util.*,com.hs.auth.model.*,com.hs.core.utils.*" pageEncoding="utf-8"%>
<%
HsAccount accObj = (HsAccount)request.getAttribute("accObj");
HsUserinfo userinfo = accObj==null?null:accObj.getUserinfo(); 
String flag = (String)request.getAttribute("flag");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<title>用户注册</title>
<%@ include file="../include.jsp"%>   
<script language="javascript" type="text/javascript" src="<%=path %>/thirtpart/My97DatePicker/WdatePicker.js"></script>

<style>.tac{text-align:center}</style>
 <script language="javascript" type="text/javascript">
 
 var flag = true;
 function callBackForCheckId(message){
 	  
 	    if("0" == message)
 	       alert("此帐号可以使用");
 	    else{
 	       alert("此帐号已存在，不可注册");  
 	    } 
 }
  function callBackForCheckId1(message){
 	  
 	    if("0" != message) {
 	       alert("此帐号已存在，不可注册"); 
 	       flag =false;
 	    } 
 }
 
 function checkUserId(){
 	 var logid = userform.loginid.value;
     if(isNull(logid)){
		        	alert("帐号不能为空!");
		            userform.loginid.focus();
		            return;
     }
     authdwr.isDouble(logid,callBackForCheckId);  
 
 }
 
 function saveData(){
            var logid = userform.loginid.value;
            var id = userform.id.value; 
             if(isNull(id)){
             	 if(isNull(logid)){
		        	alert("帐号不能为空!");
		            userform.loginid.focus();
		            return;
             	 }
              	 authdwr.isDouble(logid,callBackForCheckId1);   
             }
              setTimeout("checkform();",1000)
 	     
 
 }
 function checkform(){ 
    var logid = userform.loginid.value;
    var id = userform.id.value;
    var pwd = userform.pwd.value;
    var confirmpwd = userform.confirmpwd.value;
    var username = userform.username.value; 
    
    
     var zhicheng = userform.zhicheng.value;
     var cardtype = userform.cardtype.value;
     var cardnum = userform.cardnum.value;
     var zuigxl = userform.zuigxl.value; 
     var xuewei = userform.xuewei.value; 
     var zhuanye = userform.zhuanye.value; 
     var phone = userform.phone.value;
     var handphone = userform.handphone.value;
     var postaddress = userform.postaddress.value; 
     var email = userform.email.value; 
     var postno = userform.postno.value; 
    
        if(isNull(logid)){
        	alert("用户名不能为空!");
            userform.loginid.focus();
            return;
        }
        if(isNull(pwd)){
        	alert("密码不能为空!");
            userform.pwd.focus();
            return;
        }
        if(isNull(confirmpwd)){
        	alert("确认密码不能为空!");
            userform.confirmpwd.focus();
            return;
        }
        if( pwd != confirmpwd){
        	alert("密码与确认密码不一致!");
            userform.confirmpwd.focus();
            return;
        }
        if(isNull(username)){
        	alert("用户姓名不能为空！");
            userform.username.focus();
            return;
        }
        
        if(isNull(zhicheng)){
        	alert("请选择职称！");
            userform.zhicheng.focus();
            return;
        }
        if(isNull(cardtype)){
        	alert("请选择证件类型！");
            userform.cardtype.focus();
            return;
        }
        if(isNull(cardnum)){
        	alert("请填写证件号码！");
            userform.cardnum.focus();
            return;
        }
        if('1' == cardtype){
	   	    if(!CheckValue(cardnum))
	   	      return; 
  		 }
        if(isNull(xuewei)){
	   		alert("请选择学位！");
	   		dataform.xuewei.focus();
	   		return false; 
	   } 
	   if(isNull(zhuanye)){
	   		alert("请选择专业！");
	   		dataform.zhuanye.focus();
	   		return false; 
	   }
        if(isNull(zuigxl)){
        	alert("请选择最高学历！");
            userform.zuigxl.focus();
            return;
        }
           
     	 if(isNull(phone)){
        	alert("请填写固定电话！");
            userform.phone.focus();
            return;
        } if(isNull(handphone)){
        	alert("请填写手机号码！");
            userform.handphone.focus();
            return;
        } if(isNull(postaddress)){
        	alert("请填写通讯地址！");
            userform.postaddress.focus();
            return;
        } if(isNull(email)){
        	alert("请填写电子邮箱！");
            userform.email.focus();
            return;
        } if(isNull(postno)){
        	alert("请填写邮政编码！");
            userform.postno.focus();
            return;
        }
    if(flag)
 	  userform.submit(); 
 }
function forwardLogin(){
	document.location.href = "<%=basePath%>logon.jsp?loginid=<%=accObj==null?"":accObj.getLoginid()==null?"":accObj.getLoginid()%>";


}
 </script>
</head>
<body class="cont_body">
<form name="userform" action="<%=basePath %>auth/regsave.do" method="post">
    <table border="0" cellspacing="0" cellpadding="0" class="new">  
      <caption>用户注册(红色<font color=red>*</font>为必填项)</caption>  
      <tr>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>帐号</td>
        <td  colspan=3 nowrap><input type="text" class="form_off" name="loginid" value="<%=accObj==null?"":accObj.getLoginid()==null?"":accObj.getLoginid() %>" style="width:65%" <%if(null != accObj && null != accObj.getLoginid()){out.print(" disabled");} %>/><font color=red></font>
         <input type="hidden" name="id" value="<%=accObj==null?"":accObj.getId() %>"  />
         <input type="hidden" name="userid" value="<%=userinfo==null?"":userinfo.getId() %>"  />
        <input type="button" value="用户名检测" onclick="checkUserId();"/>
        </td> 
      </tr>
       <tr>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>密码</td>
        <td width="35%"><input type="password" name="pwd" value="" style="width:90%"></td>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>确认密码</td>
        <td width="35%"><input type="password" name="confirmpwd" value="" style="width:90%"></td>
      </tr>
      
      
      <tr>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>姓名</td>
        <td width="35%"><input type="text" name="username" value="<%=userinfo == null?"":userinfo.getUsername() %>" style="width:90%"><font color=red></font></td>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>职称</td>
        <td width="35%">
         <%=DictCacheUtil.getInst().selectStrWithDefault("zhicheng","width:90%",userinfo==null?null:(userinfo.getZhicheng())+"","9") %><font color=red></font>
       </td>  
      </tr>
       <tr>
        <td width="15%">出生年月</td>
        <td width="35%"><input type="text" class="Wdate" id="shengri" value="<%=userinfo == null?"":userinfo.getBirthday() ==null?"":userinfo.getBirthday()  %>" style="width:90%" name="shengri"  onFocus="WdatePicker({el:'shengri',dateFmt:'yyyy-MM-dd'})"  /></td>
        <td width="15%">性别</td>
        <td width="35%"><input type="radio" value='1' name="sex" <%if(userinfo == null||"1".equals(userinfo == null?"":(userinfo.getUsersex()+""))){ out.print(" checked");} %>/>男
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" value='2' name="sex" <%if("2".equals(userinfo == null?"":(userinfo.getUsersex()+""))){ out.print(" checked");} %>/>女</td>
      </tr>
       <tr>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>证件类型</td>
        <td width="35%"><%=DictCacheUtil.getInst().selectStrWithDefault("cardtype","width:90%",userinfo==null?null:(userinfo.getCardtype())+"","15") %><font color=red></font></td>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>证件号码</td>
        <td width="35%"><input type="text" name="cardnum" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getCardnum()) %>" style="width:90%"><font color=red></font></td>
      </tr>
      <tr>
       <td><font color=red><strong><b>＊</b></strong></font>专业</td>
        <td><%out.println(DictCacheUtil.getInst().selectStrWithDefault("zhuanye","width:90%",userinfo==null?"":userinfo.getSpecialtype(),"11"));%></td>
       
        <td><font color=red><strong><b>＊</b></strong></font>学位</td>
        <td><%out.println(DictCacheUtil.getInst().selectStrWithDefault("xuewei","width:90%",userinfo==null?"":userinfo.getZuizhongxw()+"","16"));%></td>
      </tr>  
       <tr>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>最高学历</td>
        <td width="35%">
        <%=DictCacheUtil.getInst().selectStrWithDefault("zuigxl","width:90%",userinfo==null?null:(userinfo.getZuigxl())+"","14") %><font color=red></font>
        <td width="15%">毕业院校</td>
        <td width="35%"><input type="text" name="school" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getBiyeyx()) %>" style="width:90%"></td>
      </tr>
       <tr>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>固定电话</td>
        <td width="35%"><input type="text" name="phone" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getPhone()) %>" style="width:90%"></td>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>手机</td>
        <td width="35%"><input type="text" name="handphone" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getHandphone()) %>" style="width:90%"></td>
      </tr> 
       <tr>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>通信地址</td>
        <td colspan=3><input type="text" name="postaddress" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getAddress()) %>" style="width:96%"></td> 
      </tr>
      <tr>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>电子邮箱</td>
        <td  ><input type="text" name="email" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getEmail()) %>" style="width:90%"></td>
        <td width="15%"><font color=red><strong><b>＊</b></strong></font>邮政编码</td>
        <td width="35%"><input type="text" name="postno" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getPostnum()) %>" style="width:90%"></td> 
      </tr> 
      <tr>
      <td colspan=4 align="center"> 
        	<input   type="button" value="提交" onclick="saveData();" class="butt2" />&nbsp;&nbsp;<%if(null !=accObj){ %><input   type="button" value="登录" onclick="forwardLogin();" class="butt2" />&nbsp;&nbsp;<%} %><input   type="button" value="关闭" onclick="window.close();" class="butt2" />
      </td> 
      </tr> 
    </table>  
</form>
</body>
</html>
<script>
<%if(null!= flag){ %> 
    alert("保存成功！");
 <%}%>
</script>
